# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=networkmanager-openconnect
pkgver=1.2.4
pkgrel=3
pkgdesc="NetworkManager VPN plugin for OpenConnect"
url="https://wiki.gnome.org/Projects/NetworkManager"
arch=(x86_64)
license=(GPL)
depends=(libnm libsecret openconnect)
makedepends=(libnm-gtk intltool python git)
_commit=5123d7622fcce22da3cea75f878410e8c6dcfd69  # tags/1.2.4^0
source=("git+https://git.gnome.org/browse/network-manager-openconnect#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd network-manager-openconnect
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd network-manager-openconnect
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd network-manager-openconnect
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
    --libexecdir=/usr/lib --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd network-manager-openconnect
  make DESTDIR="$pkgdir" install
  echo 'u nm-openconnect - "NetworkManager OpenConnect"' |
    install -Dm644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
}
